package cn.yuanqiao.archive.utils.impl;

import cn.yuanqiao.archive.utils.FilePageCounter;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.stereotype.Service;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;

/**
 * @ClassName: WordFilePageCounter
 * @Description: 类的描述
 * @author: lihuahua
 * @date: 2024/4/11 17:21
 * @Blog: huahuacoco.top
 */


@Service("WordFilePageCounter")
public class WordFilePageCounter implements FilePageCounter {

    @Override
    public int getPageCount(String filePath) throws Exception {
        try (XWPFDocument document = new XWPFDocument(new FileInputStream(filePath))) {
            return document.getProperties().getExtendedProperties().getPages();
        }
    }

    @Override
    public InputStream extractPages(String wordUrl, List<Integer> pageNumbers) throws Exception {
        // 1. 加载Word文档
        return null;
    }


}
